package com.lc.pianostudent.activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.lc.pianostudent.BaseApplication;
import com.lc.pianostudent.R;
import com.lc.pianostudent.conn.PostCustomerIndex;
import com.lc.pianostudent.util.Util;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.util.UtilApp;
import com.zcx.helper.util.UtilToast;

/**
 * Created by Administrator on 2018/6/25.
 */

public class AboutActivity extends BaseActivity implements View.OnClickListener{

    @BoundView(R.id.webview2)
    private WebView webView;

    private String url, title;//标题，链接
    @BoundView(R.id.version) private TextView version;

    @BoundView(R.id.phone) private TextView phone;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);


        setBackTrue();

        initView();
    }

    private void initView(){
        phone.setText("客服热线："+BaseApplication.BasePreferences.readKefu());
        version.setText("V"+ UtilApp.versionName());
        url = getIntent().getStringExtra("url");
        title = getIntent().getStringExtra("title");
        setBackTrue();
        setTitleName(title);

        WebSettings webSettings = webView.getSettings();
        webSettings.setAllowFileAccess(true);
        webSettings.setDomStorageEnabled(true);//允许DCOM
        webSettings.setJavaScriptEnabled(true);

        webView.loadUrl(url);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return false;
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
               case R.id.phone:
                UtilApp.call(BaseApplication.BasePreferences.readKefu());
                break;
        }
    }
}
